/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.free.ts.employee;

import be.free.ts.contact.Contact;
import be.free.ts.project.Project;
import be.free.ts.support.AbstractPersistable;
import be.free.ts.support.Interval;
import be.free.ts.support.validation.ValidInterval;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Set;

/**
 * @author Christophe De Blende
 * @since 08/12/12
 */
@Entity
public class Employee extends AbstractPersistable {

	protected Employee() {
		// use the builder
	}

	@NotNull
	@OneToOne
	private Contact contact;

	@ManyToMany
	@JoinTable(name = "EMPLOYEE_PROJECT",
			joinColumns = {@JoinColumn(name = "EMP_ID")},
			inverseJoinColumns = @JoinColumn(name = "PRJ_ID"))
	private Set<Project> projects;

	@NotNull
	@Embedded
	@ValidInterval
	private Interval interval;

	public Interval getInterval() {
		return interval;
	}

	public Contact getContact() {
		return contact;
	}

	public Set<Project> getProjects() {
		return projects;
	}

	public void setContact(Contact contact) {
		this.contact = contact;
	}

	public void setProjects(Set<Project> projects) {
		this.projects = projects;
	}

	public void setInterval(Interval interval) {
		this.interval = interval;
	}

}


